package vip.indo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import vip.indo.common.JsonResult;
import vip.indo.enums.BusinessMshEnum;
import vip.indo.exception.BusinessErrorException;

/**
 * @Author: tianlianyin
 * @Date: 2024/11/28 10:47
 * @Descripition:
 */
@RestController
@RequestMapping("/exception")
@Slf4j
public class ExceptionController {
    @GetMapping("test")
    public JsonResult test(
            @RequestParam("name") String name,
            @RequestParam("pass") String pass
    ){
        log.info("name:{},pass:{}",name,pass);
        return JsonResult.success();
    }
    @GetMapping("/business")
    public JsonResult testException(){
        try {
            int i = 1/0;
        }catch (Exception e){
            throw new BusinessErrorException(BusinessMshEnum.UNEXPECTED_EXCEPTION);
        }
        return JsonResult.success();
    }
}
